#include <stdio.h>
#include <stdlib.h>

typedef int TElemSet;

typedef struct BinaryTreeNode *BinaryTree;
struct BinaryTreeNode {
    TElemSet data; /* 数据元素 */
    BinaryTree left; /* 左孩子指针 */
    BinaryTree right; /* 右孩子指针 */
};

BinaryTree CreateBinaryTree(TElemSet value, BinaryTree left_tree,
                            BinaryTree right_tree) {
    BinaryTree tree;

    tree = (BinaryTree)malloc(sizeof(struct BinaryTreeNode));
    tree->data = value;
    tree->left = left_tree;
    tree->right = right_tree;
    return tree;
}

/* 算法5-11：二叉树前序序列化 PreOrderSerialize(tree) */
void PreOrderSerialize(BinaryTree tree) {
    if (tree == NULL) { /* 空树 */
        printf("#\n"); /* 输出特殊符号，代表空结点 */
    } else {
        printf("%d\n", tree->data); /* 输出根结点数据 */
        PreOrderSerialize(tree->left); /* 对左子树前序序列化 */
        PreOrderSerialize(tree->right);/* 对右子树前序序列化 */
    }
}
/* 算法5-11 结束 */

int main(void) {
    BinaryTree tree, left_tree, right_tree;
    TElemSet value;

    scanf("%d", &value);
    left_tree = CreateBinaryTree(value, NULL, NULL);
    scanf("%d", &value);
    right_tree = CreateBinaryTree(value, NULL, NULL);
    scanf("%d", &value);
    tree = CreateBinaryTree(value, left_tree, right_tree);
    PreOrderSerialize(tree);

    return 0;
}